<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Foundation\AliasLoader;
use App\Helpers\ErrorCodeHelper;
use App\Helpers\UniqID\UniqIDHelper;
use App\Facades\ErrorCode;
use App\Facades\UniqID;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        // if ($this->app->environment('local')) {
        //     $this->app->register(TelescopeServiceProvider::class);
        // }
        $loader = AliasLoader::getInstance();

        // 错误码单例
        $this->app->singleton('errorcode', function ($app) {
            return new ErrorCodeHelper();
        });
        // 错误码别名
        $loader->alias('ErrorCode', ErrorCode::class);
        // 唯一ID单例
        $this->app->singleton('uniqid', function ($app) {
            return new UniqIDHelper();
        });
        // 唯一ID别名
        $loader->alias('UniqID', UniqID::class);

        
        $this->app->register(RepositoryServiceProvider::class); //仓库绑定服务

    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        //
    }
}
